<!--  -->
<template>
    <div ref="menuRef" :class="['li-menu', `li-menu--${mode}`]">
        <slot></slot>
    </div>
</template>

<script lang="ts" setup>
import { ref, reactive, onBeforeMount, onMounted, computed, provide } from 'vue';

const props = defineProps({
    // 方向： horizontal 水平 (默认) | inline 竖直
    mode: {
        type: String,
        default: 'horizontal'
    },
    // 激活菜单的name值
    activeName: {
        type: [String, Number],
        default: ''
    },
    // 激活菜单的颜色
    color: {
        type: [String, Number],
        default: '#4567f1'
    }
});

const emit = defineEmits(['update:activeName']);

const menuRef = ref(null);

const activeNameEvent = (activeName: string | number) => {
    emit('update:activeName', activeName);
};
const getActiveName = (): string | number => {
    return props.activeName;
};

provide('color', props.color);
provide('mode', props.mode);
provide('activeName', props.activeName);
provide('getActiveName', getActiveName);
provide('activeNameEvent', activeNameEvent);
</script>

<style lang="less" scoped>
.li-menu {
    position: relative;
    transition: all 0.3s ease;
    // 水平
    &--horizontal {
        display: flex;
        flex-direction: row;
        align-items: center;
        border-bottom: 1px solid #fafafa;

        &::before {
            content: ' ';
            position: absolute;
            bottom: 0.5px;
            left: 0px;
            height: 1px;
            width: 100%;
            background-color: #f0f0f0;
        }
    }

    //垂直
    &--inline {
        width: 220px;
        display: flex;
        flex-direction: column;
        align-items: center;
    }
}
</style>
